#include "userwidget.h"
#include "ui_userwidget.h"
#include <QStackedWidget>

UserWidget::UserWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::UserWidget) {
    ui->setupUi(this);

    m_pUserDM = new UserDeviceMgt(this);
    m_pUserWM =new UserWarningMgt(this);

    QStackedWidget *stackedWidget = new QStackedWidget(this);

    ui->mainLayout->addWidget(stackedWidget);

    stackedWidget->addWidget(m_pUserDM);
    stackedWidget->addWidget(m_pUserWM);

    connect(ui->BtnDM, &QPushButton::clicked, this, [=](){
        stackedWidget->setCurrentIndex(0);
    });

    connect(ui->BtnWM, &QPushButton::clicked, this, [=]() {
        stackedWidget->setCurrentIndex(1);
    });

}
void UserWidget::onUserName(const QString &UserName) {
    ui->btnUserName->setText(UserName);
}

UserWidget::~UserWidget() {
    delete ui;
}


